//
// Created by hjie on 23-6-22.
//

#pragma once

#include <string>
#include <memory>
#include <vector>
#include <map>
#include <set>
#include <rapidjson/document.h>
#include "signal_thread_pool.h"

class ConnectionData;
class RoomManager;
class RoomReferenceData;
class DataManager;

class ConnectionDataRoom : public std::enable_shared_from_this<ConnectionDataRoom>
{
public:
    ConnectionDataRoom(RoomManager * room_manager, const std::string & room_id);
    ~ConnectionDataRoom();

    bool AddConnectionData(ConnectionData * data);
    void RemoveConnectionData(const std::string & user_name);

    void ProcessMessageProtocol(ConnectionData * data, rapidjson::Document & input);
    void PolicyMessage(RoomReferenceData * reference);

    std::string RoomId() { return m_room_id;}
    void OnTimer();
private:
    RoomManager * m_room_manager;
private:
    std::string m_room_id;
    std::map<std::string,ConnectionData*> m_connection_data_map;
public:
    int64_t m_last_recv_msg_time;
    std::shared_ptr<DataManager> m_data_manager;
    std::shared_ptr<MsgQueue> m_room_thread_msg_queue;
    uint64_t m_timer_count{0};
};
